package com.sctvcloud.zhaohua_sd.utils;

import android.os.Environment;
import android.text.TextUtils;

import java.io.File;

/**
 * Author: create by Administrator on 2018/6/28 10 52
 * Des: 本地通用工具
 */
public class LocalUtils {


    /**
     * 获取sd位置
     */
    public static String getSDPath() {
        String sdExtra = System.getenv("EXTERNAL_STORAGE");
        if (!TextUtils.isEmpty(sdExtra)) {
            return sdExtra;
        }
        sdExtra = Environment.getExternalStorageDirectory().getAbsolutePath();
        if (!TextUtils.isEmpty(sdExtra)) {
            return sdExtra;
        }
        sdExtra = System.getenv("SECONDARY_STORAGE");
        if (!TextUtils.isEmpty(System.getenv(sdExtra))) {
            return sdExtra;
        }
        return null;
    }

    /**
     * 获取文件长度
     * @param file
     */
    public static long getFileSize(File file) {
        if (file.exists() && file.isFile()) {
            String fileName = file.getName();
            return file.length();
        }else{
            return 0;
        }
    }

}
